#include <graphics.h>
#include<stdio.h>
#include<conio.h>
#include<iostream>
#include<math.h>
#include <fstream> 

using namespace std;
ifstream in;

class jam
{
private:
            
    float dfi,fi,l;
    float r1,c,w1,th1,m1;
    float k1,k2,k3,k4,l1,l2,l3,l4;

public:
       void initial(float, float, float, float, float);
       void prec();
};


void jam::initial(float a1,float a2,float a3,float a4,float a5)
{
     r1=a1;
     c=30*a2;
     w1=a3;
     th1=a4;
     m1=a5;

}


void jam::prec()
{
  initwindow(1100,700); 
  fi=0;
  l=10;
  dfi=10*sin(th1)/(m1*r1*r1*w1);
  while(l>0)
  {        
    for(fi=5;l>0;fi=fi+dfi)
    {
         cleardevice();
         setcolor(14);
         moveto(600,500);
    
         l1=k1;
         l2=k2;
         l3=k3;
         l4=k4;
        
         k1=c*sin(th1)*cos(fi+dfi);
         k2=c*sin(th1)*sin(fi+dfi);
         k3=c*cos(th1)-cos(fi)*(c/6);
       
         k4=c*sin(th1)*cos((fi+dfi)/2);
    
         circle(600+k2,500-k3,(k4*0.1));    
         lineto(600+k2,500-k3);

         moveto(600,500);
         setcolor(4);
         lineto(600,100);
         moveto(600,500);
         
         //cout<<fi<<" "<<dfi<<endl;


         delay(10);
         
    }

  }
  
}
  

int main()
{
    jam drop;
    float r,a,m,w,th;
    char gh;

    
    cout<<"Ispolzovat' dannye po umolchaniyu? (y-yes, n-not(vvesti cvoi dannye))"<<endl;
    cin>>gh;

    
    if(gh=='y')
    {
     r=5;
     a=10;
     m=5;
     w=5;
     th=0.785;
    }
    
    else if(gh=='n')
    {  
         

    
    cout<<"vvedite radius mahovika (sm)"<<endl;
        cout<<"recomenduetsa 5sm"<<endl;
    cin>>r;
    cout<<"vvedite rasstoyanie ot opori do mahovika (sm)"<<endl;
        cout<<"recomenduetsa 10sm"<<endl;
    cin>>a;
    cout<<"vvedite massu mahovika(kg)"<<endl;
        cout<<"recomenduetsa 1-5 kg"<<endl;
    cin>>m;
    cout<<"vvedite ckorost' vrasheniya mahovika(rad/s)"<<endl;
        cout<<"recomenduetsa 5 rad/s"<<endl;
    cin>>w;
    cout<<"vvedite ugol naklona mahovika"<<endl;
         cout<<"luboe znachenie(na skorost' precessii ne vliyaet)"<<endl;
    cin>>th;
    }

    drop.initial(r,a,w,th,m);
    drop.prec();
    
    return 0;    
}

